package com.atguigu02.fileStream;

import org.junit.Test;

import java.io.*;

public class FileStreamTest {
    //复制图片
    @Test
    public void t1() throws IOException {
//1．创建相关的File类的对象
        File srcFile = new File( "u.jpg" );
        File decFile = new File( "u_copy.jpg" );
//2．创建相关的字节流
        FileOutputStream fileOutputStream=new FileOutputStream(srcFile);
        FileInputStream fileInputStream=new FileInputStream(decFile);
//3．数据的读入和写出
        byte[] buffer=new byte[1024];
        int len;
        while((len=fileInputStream.read(buffer))!=-1){
            fileOutputStream.write(buffer,0,len);
        }
//4．关闭资源
        fileInputStream.close();
        fileOutputStream.close();

    }
}
